home *** CD-ROM | disk | FTP | other *** search
- #include <stdio.h>
- #include "defs.h"
-
- har *progname;
- har *filename;
- ixrect *pr1, *pr2;
-
- #ifdef STANDALONE
- ain(argc, argv, envp)
- #else
- asthresh_main(argc, argv, envp)
- #endif
- int argc;
- char **argv;
- char **envp;
- {
- register int i, j;
- int levels;
- int threshold;
- colormap_t colormap;
-
- threshold = -1;
- progname = strsave(argv[0]);
- parse_profile(&argc, argv, envp);
-
- while ((gc = getopt(argc, argv, "t:")) != EOF)
- switch (gc) {
- case 't':
- threshold = atoi(optarg);
- break;
- case '?':
- errflag++;
- break;
- }
-
- if (errflag)
- error((char *) 0, "Usage: %s: [-t threshold] [infile] [outfile]\n", progname);
-
- for (stream = 0; optind < argc; stream++, optind++)
- if (stream < 2 && strcmp(argv[optind], "-") != 0)
- if (freopen(argv[optind], mode[stream], f[stream]) == NULL)
- error("%s %s", PR_IO_ERR_INFILE, argv[optind]);
-
- if ((pr1 = pr_load(stdin, &colormap)) == NULL)
- error(PR_IO_ERR_RASREAD);
-
- if (threshold == -1) {
- if (bitrestrict)
- threshold = (calc_max(pr1)+1) / 2;
- else
- threshold = MAXLEVEL(pr1->pr_depth) / 2;
- }
- if ((pr2 = mem_create(pr1->pr_size.x, pr1->pr_size.y, 1)) == NULL)
- error("mem_create returned NULL");
-
- for (j = 0; j < pr1->pr_size.y; j++)
- for (i = 0; i < pr1->pr_size.x; i++)
- pr_put(pr2, i, j, (pr_get(pr1, i, j) > threshold) ? 1 : 0);
-
- pr_dump(pr2, stdout, &colormap, RT_STANDARD, 0);
- }
-